# 自定义错误的使用+raise
# 继承Except类，继承语法：类名(父类)
class Ageerror(Exception):
    def __init__(self, age):
        Exception.__init__(self)
        self.age = age

    def __str__(self):
        # pass占位符
        return "年龄错误"


# 方法入口必须为"__main__"
if __name__ == "__main__":
    age = float(input("请输入年龄：\n"))
    if age < 0 or age > 150:
        raise Ageerror(age)
    else:
        print("正常年龄：", age)
